package com.ymttest.database.sqlwapper;

import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.AppCountry;
import com.ymttest.database.model.AppCountryGroup;
import com.ymttest.utils.EnvSetup;

public class AppCountryWapper {
	SqlManager manage;

	public AppCountryWapper() {
		manage = new SqlManager("app"+ EnvSetup.getEnv());
	}
	
	
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	/**
	 * 返回sqlmanager
	 * 
	 * @return
	 */
	public SqlManager getManager() {
		return manage;
	}

	
	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}
	
	
	public List<AppCountry> selectAll(){
		List<AppCountry> result =  manage.getSelectResults("com.ymttest.database.mapping.AppCountryMapper.selectAll",null);
		manage.commit();
		return result;
	
	}
	
	public List<AppCountry> selectByCountryId(Integer countryId){
		List<AppCountry> result = manage.getSelectResults("com.ymttest.database.mapping.AppCountryMapper.selectByCountryId",countryId);
		manage.commit();
		return result;
	}
	

	
	public static void main(String[] args) throws InterruptedException {
	System.out.print(new AppCountryWapper().selectByCountryId(2).size());
		
	}
}
